package gui;

import java.awt.Color;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JComboBox;


import javax.swing.JButton;
import javax.swing.JCheckBox;


public class Order2 extends JPanel {
	
	private Order1 ord1;
	private Order3 order3;
	
	static int statecount=0;
	static int SelfDelivaryState=0;
	
	private JLabel jLabelGreeting = null;
	private JButton jButtonHelp = null;
	JButton jButtonExit = null;
	JButton jButtonNext = null;
	JButton jButtonBack = null;
	private JCheckBox jCheckBoxDelivary = null;
	static JTextArea jTextAreaGreeting = null;
	private JLabel jLabelDelivary = null;
	private JLabel jLabelDelivaryLogo = null;
	private JLabel jLabelStreet = null;
	static JTextField jTextFieldStreet = null;
	private JLabel jLabelDate = null;
	private JLabel jLabelTime = null;
	private JLabel jLabelFormatTime = null;
	private JLabel jLabelFormatDate = null;
	static JTextField jTextFieldDay = null;
	private JLabel jLabel1 = null;
	static JTextField jTextFieldMonth = null;
	private JLabel jLabel2 = null;
	static JTextField jTextFieldYear = null;
	private JLabel jLabelDay = null;
	private JLabel jLabelMonth = null;
	private JLabel jLabelYear = null;
	static JTextField jTextFieldHour = null;
	private JLabel jLabel4 = null;
	static JTextField jTextFieldMinute = null;
	private JLabel jLabelHour = null;
	private JLabel jLabelMinute = null;
	private JLabel jLabelReciever = null;
	static JTextField jTextFieldReciever = null;
	private JLabel jLabelPhone = null;
	static JTextField jTextFieldPhone = null;
	private JLabel jLabelAdd = null;
	private JCheckBox jCheckBoxSelf = null;
	private JLabel jLabelSelf = null;

	/**
	 * This is the default constructor
	 */
	public Order2() {
		super();
		initialize();
	}

	/**
	 * This method initializes order2
	 */
	public void initialize() {
		jLabelSelf = new JLabel();
		jLabelSelf.setBounds(new Rectangle(64, 281, 112, 27));
		jLabelSelf.setText("SELF-SHIPING");
		jLabelAdd = new JLabel();
		jLabelAdd.setBounds(new Rectangle(42, 342, 141, 29));
		jLabelAdd.setText("~~ADDITIONAL 30 NIS~~");
		jLabelPhone = new JLabel();
		jLabelPhone.setBounds(new Rectangle(43, 479, 148, 33));
		jLabelPhone.setText("PHONE OF THE RECIEVER:");
		jLabelPhone.setVisible(false);
		jLabelReciever = new JLabel();
		jLabelReciever.setBounds(new Rectangle(43, 439, 149, 34));
		jLabelReciever.setText("NAME OF THE RECIEVER:");
		jLabelReciever.setVisible(false);
		jLabelMinute = new JLabel();
		jLabelMinute.setBounds(new Rectangle(247, 629, 52, 28));
		jLabelMinute.setText("MINUTE");
		jLabelMinute.setVisible(false);
		jLabelHour = new JLabel();
		jLabelHour.setBounds(new Rectangle(181, 629, 42, 29));
		jLabelHour.setText("HOUR");
		jLabelHour.setVisible(false);
		jLabel4 = new JLabel();
		jLabel4.setBounds(new Rectangle(230, 659, 12, 38));
		jLabel4.setText(":");
		jLabel4.setVisible(false);
		jLabelYear = new JLabel();
		jLabelYear.setBounds(new Rectangle(320, 552, 40, 27));
		jLabelYear.setText("YEAR");
		jLabelYear.setVisible(false);
		jLabelMonth = new JLabel();
		jLabelMonth.setBounds(new Rectangle(248, 552, 49, 28));
		jLabelMonth.setText("MONTH");
		jLabelMonth.setVisible(false);
		jLabelDay = new JLabel();
		jLabelDay.setBounds(new Rectangle(179, 554, 37, 24));
		jLabelDay.setText("DAY");
		jLabelDay.setVisible(false);
		jLabel2 = new JLabel();
		jLabel2.setBounds(new Rectangle(300, 586, 16, 29));
		jLabel2.setText("/");
		jLabel2.setVisible(false);
		jLabel1 = new JLabel();
		jLabel1.setBounds(new Rectangle(224, 584, 19, 33));
		jLabel1.setText("/");
		jLabel1.setVisible(false);
		jLabelFormatDate = new JLabel();
		jLabelFormatDate.setBounds(new Rectangle(366, 586, 160, 34));
		jLabelFormatDate.setText("IN FORMAT OF 01/01/01");
		jLabelFormatDate.setVisible(false);
		jLabelFormatTime = new JLabel();
		jLabelFormatTime.setBounds(new Rectangle(299, 662, 159, 31));
		jLabelFormatTime.setText("IN FORMAT OF 12:30");
		jLabelFormatTime.setVisible(false);
		jLabelTime = new JLabel();
		jLabelTime.setBounds(new Rectangle(43, 662, 122, 32));
		jLabelTime.setText("TIME TO DELIVER:");
		jLabelTime.setVisible(false);
		jLabelDate = new JLabel();
		jLabelDate.setBounds(new Rectangle(45, 586, 121, 31));
		jLabelDate.setText("DATE OF DELIVARY:");
		jLabelDate.setVisible(false);
		jLabelStreet = new JLabel();
		jLabelStreet.setBounds(new Rectangle(43, 517, 69, 33));
		jLabelStreet.setText("ADDRESS:");
		jLabelStreet.setVisible(false);
		jLabelDelivaryLogo = new JLabel();
		ImageIcon imageLogo = new ImageIcon("floral_delivery.jpg");
		jLabelDelivaryLogo.setIcon(imageLogo);
		jLabelDelivaryLogo.setBounds(new Rectangle(183, 296, 252, 139));
		jLabelDelivaryLogo.setVisible(false);
		jLabelDelivary = new JLabel();
		jLabelDelivary.setBounds(new Rectangle(66, 310, 110, 30));
		jLabelDelivary.setText("ADD DELIVARY");
		jLabelGreeting = new JLabel();
		jLabelGreeting.setBounds(new Rectangle(28, 51, 150, 44));
		jLabelGreeting.setText("ADD GREETING CARD:");
		this.setSize(600, 800);
		this.setLayout(null);
		this.setBackground(Color.cyan);
		this.add(jLabelGreeting, null);
		this.add(getJButtonHelp(), null);
		this.add(getJButtonExit(), null);
		this.add(getJButtonNext(), null);
		this.add(getJButtonBack(), null);
		this.add(getJCheckBoxDelivary(), null);
		this.add(getJTextAreaGreeting(), null);
		this.add(jLabelDelivary, null);
		this.add(jLabelDelivaryLogo, null);
		this.add(jLabelStreet, null);
		this.add(getJTextFieldStreet(), null);
		this.add(jLabelDate, null);
		this.add(jLabelTime, null);
		this.add(jLabelFormatTime, null);
		this.add(jLabelFormatDate, null);
		this.add(getJTextFieldDay(), null);
		this.add(jLabel1, null);
		this.add(getJTextFieldMonth(), null);
		this.add(jLabel2, null);
		this.add(getJTextFieldYear(), null);
		this.add(jLabelDay, null);
		this.add(jLabelMonth, null);
		this.add(jLabelYear, null);
		this.add(getJTextFieldHour(), null);
		this.add(jLabel4, null);
		this.add(getJTextFieldMinute(), null);
		this.add(jLabelHour, null);
		this.add(jLabelMinute, null);
		this.add(jLabelReciever, null);
		this.add(getJTextFieldReciever(), null);
		this.add(jLabelPhone, null);
		this.add(getJTextFieldPhone(), null);
		this.add(jLabelAdd, null);
		this.add(getJCheckBoxSelf(), null);
		this.add(jLabelSelf, null);
	}


	/**
	 * This method initializes jButtonHelp and opens the help screen
	 * @return
	 */
	private JButton getJButtonHelp() {
		if (jButtonHelp == null) {
			jButtonHelp = new JButton();
			jButtonHelp.setBounds(new Rectangle(18, 734, 106, 45));
			jButtonHelp.setText("HELP");
			jButtonHelp.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					HelpFrame HFrame = new HelpFrame();

					HFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					HFrame.setSize( 600,720 ); // set frame size
					HFrame.setResizable(false);
					HFrame.setVisible( true ); // display frame
				}
			});
		}
		return jButtonHelp;
	}

	/**
	 * This method initializes jButtonExit and opens the exit screen	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonExit() {
		if (jButtonExit == null) {
			jButtonExit = new JButton();
			jButtonExit.setBounds(new Rectangle(483, 734, 91, 45));
			jButtonExit.setText("EXIT");

		}
		return jButtonExit;
	}

	/**
	 * This method initializes jButtonNext and opens the Order3 screen. also takes all data in the screen and puts them in a vector
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonNext() {
		if (jButtonNext == null) {
			jButtonNext = new JButton();
			jButtonNext.setBounds(new Rectangle(394, 734, 83, 45));
			jButtonNext.setText("NEXT");
			
					
		}
		return jButtonNext;
	}

	/**
	 * This method initializes jButtonBack and opens the Order1 screen
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonBack() {
		if (jButtonBack == null) {
			jButtonBack = new JButton();
			jButtonBack.setBounds(new Rectangle(301, 735, 87, 44));
			jButtonBack.setText("BACK");
		}
		return jButtonBack;
	}

	/**
	 * This method initializes jCheckBoxDelivary	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxDelivary() {
		if (jCheckBoxDelivary == null) {
			jCheckBoxDelivary = new JCheckBox();
			jCheckBoxDelivary.setBounds(new Rectangle(39, 309, 25, 31));
			jCheckBoxDelivary.setBackground(Color.cyan);
			jCheckBoxDelivary.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					statecount++;
					if (!((statecount%2)==0))
					{
					jLabelFormatDate.setVisible(true);
					jLabelFormatTime.setVisible(true);
					jLabelTime.setVisible(true);
					jLabelDate.setVisible(true);
					jLabelStreet.setVisible(true);
					jLabelDelivaryLogo.setVisible(true);
					jTextFieldStreet.setVisible(true);
					jLabelMinute.setVisible(true);
					jLabelHour.setVisible(true);
					jLabel4.setVisible(true);
					jLabelYear.setVisible(true);
					jLabelMonth.setVisible(true);
					jLabelDay.setVisible(true);
					jLabel2.setVisible(true);
					jLabel1.setVisible(true);
					jTextFieldDay.setVisible(true);
						jTextFieldMonth.setVisible(true);
						jTextFieldYear.setVisible(true);
						jTextFieldHour.setVisible(true);
						jTextFieldMinute.setVisible(true);					
						jLabelPhone.setVisible(true);
						jLabelReciever.setVisible(true);
						jTextFieldReciever.setVisible(true);
						jTextFieldPhone.setVisible(true);
					}
					else
					{
						jLabelFormatDate.setVisible(false);
						jLabelFormatTime.setVisible(false);
						jLabelTime.setVisible(false);
						jLabelDate.setVisible(false);
						jLabelStreet.setVisible(false);
						jLabelDelivaryLogo.setVisible(false);
						jTextFieldStreet.setText(null);
						jTextFieldDay.setText(null);
						jTextFieldMonth.setText(null);
						jTextFieldYear.setText(null);
						jTextFieldHour.setText(null);
						jTextFieldMinute.setText(null);
						jTextFieldStreet.setVisible(false);
						jLabelMinute.setVisible(false);
						jLabelHour.setVisible(false);
						jLabel4.setVisible(false);
						jLabelYear.setVisible(false);
						jLabelMonth.setVisible(false);
						jLabelDay.setVisible(false);
						jLabel2.setVisible(false);
						jLabel1.setVisible(false);
						jTextFieldDay.setVisible(false);
							jTextFieldMonth.setVisible(false);
							jTextFieldYear.setVisible(false);
							jTextFieldHour.setVisible(false);
							jTextFieldMinute.setVisible(false);
							jLabelPhone.setVisible(false);
							jLabelReciever.setVisible(false);
							jTextFieldReciever.setVisible(false);
							jTextFieldPhone.setVisible(false);
					}
				}
			});
		}
		return jCheckBoxDelivary;
	}

	/**
	 * This method initializes jTextAreaGreeting	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getJTextAreaGreeting() {
		if (jTextAreaGreeting == null) {
			jTextAreaGreeting = new JTextArea();
			jTextAreaGreeting.setBounds(new Rectangle(194, 54, 317, 236));
		}
		return jTextAreaGreeting;
	}

	/**
	 * This method initializes jTextFieldStreet	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldStreet() {
		if (jTextFieldStreet == null) {
			jTextFieldStreet = new JTextField();
			jTextFieldStreet.setBounds(new Rectangle(118, 517, 406, 33));
			jTextFieldStreet.setVisible(false);
		}
		return jTextFieldStreet;
	}

	/**
	 * This method initializes jTextFieldDay	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldDay() {
		if (jTextFieldDay == null) {
			jTextFieldDay = new JTextField();
			jTextFieldDay.setBounds(new Rectangle(180, 584, 36, 34));
			jTextFieldDay.setVisible(false);
		}
		return jTextFieldDay;
	}

	/**
	 * This method initializes jTextFieldMonth	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldMonth() {
		if (jTextFieldMonth == null) {
			jTextFieldMonth = new JTextField();
			jTextFieldMonth.setBounds(new Rectangle(255, 586, 32, 31));
			jTextFieldMonth.setVisible(false);
		}
		return jTextFieldMonth;
	}

	/**
	 * This method initializes jTextFieldYear	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldYear() {
		if (jTextFieldYear == null) {
			jTextFieldYear = new JTextField();
			jTextFieldYear.setBounds(new Rectangle(324, 584, 32, 34));
			jTextFieldYear.setVisible(false);
		}
		return jTextFieldYear;
	}

	/**
	 * This method initializes jTextFieldHour	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldHour() {
		if (jTextFieldHour == null) {
			jTextFieldHour = new JTextField();
			jTextFieldHour.setBounds(new Rectangle(181, 660, 45, 35));
			jTextFieldHour.setVisible(false);
		}
		return jTextFieldHour;
	}

	/**
	 * This method initializes jTextFieldMinute	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldMinute() {
		if (jTextFieldMinute == null) {
			jTextFieldMinute = new JTextField();
			jTextFieldMinute.setBounds(new Rectangle(249, 658, 44, 38));
			jTextFieldMinute.setVisible(false);
		}
		return jTextFieldMinute;
	}

	/**
	 * This method initializes jTextFieldReciever	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldReciever() {
		if (jTextFieldReciever == null) {
			jTextFieldReciever = new JTextField();
			jTextFieldReciever.setBounds(new Rectangle(195, 439, 190, 33));
			jTextFieldReciever.setVisible(false);
		}
		return jTextFieldReciever;
	}

	/**
	 * This method initializes jTextFieldPhone	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldPhone() {
		if (jTextFieldPhone == null) {
			jTextFieldPhone = new JTextField();
			jTextFieldPhone.setBounds(new Rectangle(195, 480, 190, 32));
			jTextFieldPhone.setVisible(false);
		}
		return jTextFieldPhone;
	}

	/**
	 * This method initializes jCheckBoxSelf	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxSelf() {
		if (jCheckBoxSelf == null) {
			jCheckBoxSelf = new JCheckBox();
			jCheckBoxSelf.setBounds(new Rectangle(39, 283, 27, 26));
			jCheckBoxSelf.setBackground(Color.cyan);
			jCheckBoxSelf.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					SelfDelivaryState++;					 
				}
			});
		}
		return jCheckBoxSelf;
	}
	
	
}
